package com.innovation.chengzhangriji.ui.widget;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.v7.widget.RecyclerView;
import android.view.View;

public class FriendItemDecoration extends RecyclerView.ItemDecoration {

    private Paint paintLine;

    //private Paint paint;

    public FriendItemDecoration() {
        paintLine = new Paint();
        //paint = new Paint();
        paintLine.setColor(Color.rgb(224, 224, 224));
        //paint.setColor(Color.rgb(229, 229, 229));
    }

    @Override
    public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
        super.onDrawOver(c, parent, state);
        final int childCount = parent.getChildCount();
        for (int i = 0; i < childCount - 1; i++) {
            final View child = parent.getChildAt(i);
            // c.drawRect(child.getLeft(), child.getBottom(), child.getRight(), child.getBottom() + 8 * parent.getContext().getResources().getDisplayMetrics().density, paint);
            c.drawLine(child.getLeft(), child.getBottom() + parent.getContext().getResources().getDisplayMetrics().density, child.getRight(), child.getBottom() + parent.getContext().getResources().getDisplayMetrics().density, paintLine);
        }
    }

}
